using HKB.Common;
using System;
using System.Web;
namespace HKB.Web.Admin
{
	public class Admin : HoWave_Root
	{
		private OnlineAdmin _admin = null;
		private string actionTabTabInfo = "";
		protected OnlineAdmin admin
		{
			get
			{
				OnlineAdmin admin;
				if (this._admin == null)
				{
					this._admin = new OnlineAdmin(this.conn);
					admin = this._admin;
				}
				else
				{
					admin = this._admin;
				}
				return admin;
			}
		}
		public string ActionTabInfo
		{
			get
			{
				if (base.Request.QueryString["action"] != null)
				{
					this.actionTabTabInfo = base.Request.QueryString["action"].Trim();
				}
				else
				{
					this.actionTabTabInfo = "";
				}
				return this.actionTabTabInfo;
			}
		}
		public Admin()
		{
			if (!this.admin.CheckAdminLogin())
			{
				HttpContext.Current.Response.Redirect("Admin_Login.aspx");
				HttpContext.Current.Response.End();
			}
		}
		public void WriteLog(string logtype, string OperatObject, string AppModule)
		{
			LogBll logBll = new LogBll(this.conn);
			logBll.AddLog(logtype, Fetch.CurrentUrl, OperatObject, DateTime.Now, this.admin.AdminName, Fetch.UserIp, Fetch.webDomain, 0, AppModule);
		}
		protected override void WriteErrMsg(string errType, string msg, string ComeUrl)
		{
			if (errType == "")
			{
				errType = Language.Get("Common/ErrTitle");
			}
			string newValue;
			if (ComeUrl != "")
			{
				newValue = "<a id=\"Button\" href='" + ComeUrl + "'>确定</a>";
			}
			else
			{
				newValue = "<a id=\"Button\" href='javascript:history.back();'>返回</a>";
			}
			string text = Template.GetTemplate(Template.GetTemplatePath("AdminError"));
			text = text.Replace("{$Title}", errType);
			text = text.Replace("{$Msg}", msg);
			text = text.Replace("{$Button}", newValue);
			text = text.Replace("{$ComeUrl}", ComeUrl);
			HttpContext.Current.Response.Write(text);
			this.Finish();
			HttpContext.Current.Response.End();
		}
		protected override void WriteSuccessMsg(string errType, string msg, string ComeUrl)
		{
			if (errType == "")
			{
				errType = Language.Get("Common/SuccessTitle");
			}
			string newValue;
			if (ComeUrl != "")
			{
				newValue = "<a id=\"Button\" href='" + ComeUrl + "'>确定</a>";
			}
			else
			{
				newValue = "<a id=\"Button\" href='javascript:history.back();'>返回</a>";
			}
			string text = Template.GetTemplate(Template.GetTemplatePath("AdminSuccess"));
			text = text.Replace("{$Title}", errType);
			text = text.Replace("{$Msg}", msg);
			text = text.Replace("{$Button}", newValue);
			text = text.Replace("{$ComeUrl}", ComeUrl);
			HttpContext.Current.Response.Write(text);
			this.Finish();
			HttpContext.Current.Response.End();
		}
		protected void WriteRightErrMsg()
		{
			this.WriteErrMsg("", Language.GetAdminMsg("Common/RightErr"), "");
		}
	}
}
